<template>
  <div class="tab-list-container">
    <div class="tab-nav-wrap">
      <ul class="tab-nav bid-flex">
        <li
          v-for="(item, index) in headerData.navData"
          :class="activeNav(item)"
          :key="index"
          @click="onNavClick(item)"
          class="nav-item"
        >
          {{ item.text }}
        </li>
      </ul>
    </div>
    <div class="tab-content-wrap">
      <div v-for="item in 8" :key="item" class="news-item bid-flex">
        <p class="i-title">{{ newsTitle[0] }}</p>
        <p>2021-06-21</p>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "tab-list",
  props: {
    headerData: {
      type: Object,
      required: true
    }
  },
  data() {
    var tempId = 0;
    if (this.headerData.navData[0]) {
      tempId = this.headerData.navData[0].id;
    }
    return {
      active: tempId,
      newsTitle: ["中招协组织集体收看庆祝中国共产党成立100周年大会"]
    };
  },
  methods: {
    onNavClick(data) {
      if (data && data.id) this.active = data.id;
    },
    activeNav(item) {
      if (item && item.id) {
        return item.id == this.active ? "active" : "none";
      }
    }
  }
};
</script>
<style scoped>
.tab-nav-wrap {
  background-color: #f0f0f0;
}

.nav-item {
  height: 0.44rem;
  padding: 0 0.17rem;
  line-height: 0.44rem;
  font-size: 0.16rem;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-item {
  color: #1571ba;
  border-bottom: 0.01rem solid #4387e6;
  border-top: 0.01rem solid #ddd;
  background-color: #f0f0f0;
  box-sizing: border-box;
}

.tab-nav .nav-item:first-child {
  border-left: 0.01rem solid #ddd;
}

.tab-nav .nav-item:last-child {
  flex: 2;
  border-right: 0.01rem solid #ddd;
}

.tab-nav .nav-item.active {
  border-left: 0.01rem solid #4387e6;
  border-right: 0.01rem solid #4387e6;
  border-top: 0.02rem solid #1571ba;
  border-bottom: none;
  background-color: #fff;
}

.news-item {
  padding: 0 0.1rem;
  justify-content: space-between;
  height: 0.42rem;
  line-height: 0.42rem;
  font-size: 0.15rem;
  overflow: hidden;
}

.i-title {
  font-size: 0.15rem;
}

.tab-content-wrap {
  border-left: 0.01rem solid #4387e6;
  border-right: 0.01rem solid #4387e6;
  border-bottom: 0.01rem solid #4387e6;
}
</style>
